package com.wyyx.api;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.wyyx.services.OrderAddServices;
import com.wyyx.services.UserRegisterServices;

import commons.Constants;
import commons.JsonResult;
import commons.JsonResultWriter;

/**
 * 添加商品订单
 */
@WebServlet("/api/OrderAdd")
public class OrderAddServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String orderUserId=request.getParameter("orderUserId") ;
		String orderPrice=request.getParameter("orderPrice") ;
		JsonResult result =null;
		try {
			OrderAddServices orderAddServices = new OrderAddServices();
			String orderId = orderAddServices.orderAdd(orderUserId, orderPrice);
			if (!orderId.isEmpty()) {
				result=new JsonResult(orderId, "添加成功",Constants.STATUS_SUCCESS);
			} else {
				result=new JsonResult("", "请检查信息",Constants.STATUS_NOTFOUND);
			}
		} catch (Exception e) {
			result=new JsonResult(e.getMessage(), "添加失败", Constants.STATUS_EX);
		}
		JsonResultWriter.writer(response, result);
	}
}
